//
//  ExamBottomView.m
//  jinnengExam
//
//  Created by mac on 2020/8/14.
//  Copyright © 2020 jznrj. All rights reserved.
//

#import "ExamBottomView.h"
#import <Masonry.h>
@implementation ExamBottomView

- (id)init
{
    self = [super init];
    if (!self) {
       return nil;
    }

    return self;
}
-(void)setUpView{
    // Initialization code
     self.previewButton = [[CustomMenuButton alloc] init];
    [self addSubview:self.previewButton ];
    [self.previewButton  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self).multipliedBy(0.3);
        make.height.mas_equalTo(self.mas_height);
        make.left.top.equalTo(self);
    }];
    self.previewButton.tag = 100;
    [self.previewButton  setButtonInfo:@{@"title":@"上一题", @"icon":@"icon_preview",@"highlightIcon":@"icon_preview_pressed"}];
    [self.previewButton  addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
   
    
    self.nextButton = [[CustomMenuButton alloc] init];
    [self addSubview:self.nextButton];
    [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self).multipliedBy(0.3);
        make.height.equalTo(self);
        make.top.equalTo(self);
        make.centerX.equalTo(self);
    }];
    
    self.nextButton.tag = 101;
    [self.nextButton setButtonInfo:@{@"title":@"下一题", @"icon":@"icon_next",@"highlightIcon":@"icon_next_pressed"}];
    [self.nextButton  addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];

    
    self.submitButton = [[CustomMenuButton alloc] init];
    
    [self addSubview:self.submitButton];
    [self.submitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self).multipliedBy(0.3);
        make.height.mas_equalTo(self.mas_height);
        make.top.equalTo(self);
        make.right.equalTo(self);
    }];
    self.submitButton.tag = 102;
    [self.submitButton setButtonInfo:@{@"title":@"交卷", @"icon":@"icon_submit",@"highlightIcon":@"icon_submit_pressed"}];
    [self.submitButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];

    
    self.userInteractionEnabled = YES;

}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */
- (void)buttonAction:(id)sender
{
    if (self.delegate == nil) {
        return;
    }
    UIButton *button = (UIButton *)sender;
    NSInteger tag = button.tag;
    if (tag == 100) { // 上一题
        [self.delegate onButtonAction:0];
    }
    else if (tag == 101) { // 下一题
        [self.delegate onButtonAction:1];
    }
    else if (tag == 102) { // 显示答案
        [self.delegate onButtonAction:2];
    }
}


@end
